package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.entity.Message;
import com.example.demo.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class GetUserController {
    @RequestMapping("/getUser")
    public void getUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
           // System.out.println(UserHolder.getUser());
            response.getWriter().write(JSONObject.toJSONString(Message.success(user)));
    }
}
